
/*

Design Pattern Automation Toolkit.
Application to create applications with emphasis on Design patterns.
And support for round trip engineering.
Copyright (C) 2004 Vineeth Neelakant. nvineeth@gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
using System;
using System.Reflection;
using System.Collections;
using DesignPatternDefinitions;


namespace DotNetReverseEngineering
{
	/// <summary>
	/// Ifield implemetnation
	/// </summary>
	public class RevEnggFieldInfo: IField
	{
		FieldInfo field;
		Hashtable metaInfo;	
		public RevEnggFieldInfo(FieldInfo fld)
		{
			this.field = fld;
			metaInfo = new Hashtable();
			this.InitMetaInfo();
		}
		
		private void InitMetaInfo()
		{
			string minfo="";
			if( this.field.IsStatic ) minfo+="static";
			if(this.field.IsAssembly) minfo+=" "+"internal";
			if(this.field.IsInitOnly) minfo+=" "+"final";
			if(this.field.IsNotSerialized) minfo+=" "+ "NonSerialized";
			this.metaInfo.Add(RevEnggClassInfo.csharp,minfo);
		}
		#region IField Members

		public string FieldVisibility
		{
			get
			{
				if( this.field.IsPublic )
					return DesignPatternDefinitions.AccessModifiers.Public.ToString().ToLower();
				if( this.field.IsPrivate)
					return DesignPatternDefinitions.AccessModifiers.Private.ToString().ToLower();
				return DesignPatternDefinitions.AccessModifiers.Protected.ToString().ToLower();


			}
			set
			{
				//not required
			}
		}

		public void SetMetaInfo(string metaInfo)
		{
			//not required
		}

		public string FieldName
		{
			get
			{
				return this.field.Name;
			}
			set
			{}
		}

		public string GetMetaInfo(string language)
		{
			return "";			
		}

		public Hashtable GetAllMetaInfo()
		{
			
			return metaInfo;
		}

		public object FieldUID
		{
			get
			{
			//not required......will not be used!
				return null;
			}
		}

		public string FieldSummary
		{
			get
			{
				// TODO:  Add RevEnggFieldInfo.FieldSummary getter implementation
				return string.Empty;
			}
			set
			{
				
			}
		}

		public string UMLRepresentation
		{
			get
			{
				return null;
			}
		}

		public string FieldType
		{
			get
			{
				return this.field.FieldType.Name;
			}
			set
			{
				
			}
		}

		#endregion
	}
}
